package com.liulin.system.controller;

import com.liulin.system.entity.Medicalchart;
import com.liulin.system.service.MedicalchartService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

/**
 * (Medicalchart)表控制层
 *
 * @author makejava
 * @since 2021-06-22 19:16:41
 */
@RestController
@RequestMapping("medicalchart")
@CrossOrigin
public class MedicalchartController {
    /**
     * 服务对象
     */
    @Resource
    private MedicalchartService medicalchartService;

    /**
     * 通过主键查询单条数据
     *
     * @param mnum 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Medicalchart selectOne(Integer mnum) {
        return this.medicalchartService.queryById(mnum);
    }

    @GetMapping("/deleteOne")
    public Boolean deleteOne(Integer mnum){
        return this.medicalchartService.deleteById(mnum);
    }

    @GetMapping("/addOne")
    public Medicalchart addOne( Integer sno, String dname,String diagnosis){
        Medicalchart medicalchart=new Medicalchart();
        //medicalchart.setMnum(mnum);
        medicalchart.setSno(sno);
        medicalchart.setDname(dname);
        medicalchart.setMdate(new Date());
        medicalchart.setDiagnosis(diagnosis);
        return  this.medicalchartService.insert(medicalchart);
    }

    @GetMapping("/updateOne")
    public  Medicalchart updateOne(Integer mnum, Integer sno, String dname,String diagnosis){
        Medicalchart medicalchart=new Medicalchart();
        medicalchart.setMnum(mnum);
        medicalchart.setSno(sno);
        medicalchart.setDname(dname);
        medicalchart.setMdate(new Date());
        medicalchart.setDiagnosis(diagnosis);
        return  this.medicalchartService.update(medicalchart);
    }

}
